﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyNet.Componets.Core.Excels
{
    public interface IExcel
    {
        #region Properties
        /// <summary>
        /// 当前操作的 SheetName
        /// </summary>
        string CurrentSheetName { get; }

        /// <summary>
        /// 当前操作的 SheetIndex
        /// </summary>
        int CurrentSheetIndex { get; }

        /// <summary>
        /// 当前操作的 RowIndex
        /// </summary>
        int CurrentRowIndex { get; }

        /// <summary>
        /// 当前操作的 ColumnIndex
        /// </summary>
        int CurrentColumnIndex { get; }

        /// <summary>
        /// 激活的 SheetIndex
        /// </summary>
        int ActiveSheetIndex { get; }
        #endregion
        
        /// <summary>
        /// 打开文件
        /// </summary>
        /// <param name="file">文件名</param>
        void Open(string file);
        
        /// <summary>
        /// 激活Sheet
        /// </summary>
        /// <param name="sheetIndex">Sheet索引号：起始索引号从0开始</param>
        void ActiveSheet(int sheetIndex);

        /// <summary>
        /// 创建Sheet
        /// 被创建的Sheet将会成为当前操作的Sheet
        /// </summary>
        void CreateSheet();

        /// <summary>
        /// 创建Sheet
        /// 被创建的Sheet将会成为当前Sheet
        /// </summary>
        /// <param name="sheetName"></param>
        void CreateSheet(string sheetName);

        /// <summary>
        /// 设置当前Sheet
        /// </summary>
        /// <param name="sheetName"></param>
        void SetCurrentSheet(string sheetName);

        /// <summary>
        /// 设置当前Sheet
        /// </summary>
        /// <param name="sheetIndex">Sheet索引号：起始从0开始</param>
        void SetCurrentSheet(int sheetIndex);

        /// <summary>
        /// 激活公式
        /// </summary>
        void ActiveFormula();

        /// <summary>
        /// 禁用公式
        /// </summary>
       void DisableFormula();

        /// <summary>
        /// 设置当前Row
        /// </summary>
        /// <param name="rowIndex">行索引号：起始索引从0开始</param>
        void SetCurrentRow(int rowIndex);

        /// <summary>
        /// 创建Row
        /// 被创建的Row会被设置成新的CurrentRow
        /// </summary>
        /// <param name="rowIndex">行索引号：起始索引从0开始</param>
        void CreateRow(int rowIndex);

        /// <summary>
        /// 创建Cell
        /// 被创建的 Cell 会被设置成新的 CurrentCell
        /// </summary>
        /// <param name="columnIndex">列索引号：起始索引从0开始</param>
        void CreateCell(int columnIndex);

        /// <summary>
        /// 设置当前单元格
        /// </summary>
        /// <param name="columnIndex">列索引号：起始索引从0开始</param>
        void SetCurrentCell(int columnIndex);

        /// <summary>
        /// 读取 当前单元格值
        /// </summary>
        /// <returns>单元格值</returns>
        object ReadCell();


        /// <summary>
        /// 写 当前单元格值
        /// </summary>
        /// <param name="obj">值对象</param>
        void WriteCell(object obj);

        /// <summary>
        /// 设置单元格 公式
        /// </summary>
        /// <param name="formula">公式</param>
        void WriteCellFormula(string formula);

        /// <summary>
        /// 保存文件
        /// </summary>
        /// <param name="file">文件路径</param>
        /// <param name="isReplace">是否替换</param>
        void Save(string file, bool isReplace);

        void Save(Stream stream);

        byte[] Save();
    }
}
